package cn.changein.framework.constant;

import java.util.Objects;

/**
 * <p>小数点保留位数</p>

 * @date: 2020-11-25 15:02
 * @copyright: 广州普微科技有限公司
 */
public enum DecimalScaleEnum {

    ratioScale("COMMON_RATIO_SCALE", 2, "比例小数点保留位数"),
    useNumberScale("COMMON_USE_NUMBER_SCALE", 2, "用量小数点保留位数"),
    copiesScale("COMMON_COPIES_SCALE", 2, "份数小数点保留位数");

    private String code;

    private Integer defaultValue;

    private String desc;

    private DecimalScaleEnum(String code, Integer defaultValue, String desc){
        this.code = code;
        this.defaultValue = defaultValue;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Integer getDefaultValue() {
        return defaultValue;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public void setDefaultValue(Integer defaultValue) {
        this.defaultValue = defaultValue;
    }

    public static Integer getDefaultValueByCode(String code){
        for(DecimalScaleEnum decimalScaleEnum : DecimalScaleEnum.values()){
            if(Objects.equals(decimalScaleEnum.getCode(), code)){
                return decimalScaleEnum.defaultValue;
            }
        }
        return 0;
    }
}
